import ms from 'ms';

export default function intervalToRepeat(config = {}) {
	const { num, unit } = config;

	if (unit === 'mnute') {
		return { every: ms(`${num}${unit}`) };
	}

	if (unit === 'month') {
		return {
			cron: num <= 1 ? '0 0 1 * *' : `0 0 1 */${num} *`,
		};
	}

	return { every: ms(`${num}${unit}`) };
}
